home *** CD-ROM | disk | FTP | other *** search
- ; Bitmap rotation engine, v3.0
- ; by Maple Leaf, 22 Oct 96
- ;
- ; This version deals with 256x256 bitmaps !
- ; --------------------------------------------------------------------------
- ; Two times smaller than the 320x200 version, and almost two times faster!
- ; (take a look at the differences between this version and the previous one)
- ; --------------------------------------------------------------------------
- ; asm rules, yup yup! the others suck!
-
- .model TPascal
- .386
- .DATA
-
- extrn _Ax_ : WORD
- extrn _Ay_ : WORD
- extrn _Bx_ : WORD
- extrn _By_ : WORD
- extrn _Cx_ : WORD
- extrn _Cy_ : WORD
- extrn vScr:WORD
- extrn Img:DWORD
- extrn Angle:BYTE
- extrn WW:WORD
- extrn WH:WORD
- extrn CosTab:BYTE
- extrn SinTab:BYTE
-
- .CODE
-
- public GenFrame
-
- include jumps.inc
-
- ;****************************************************************************
-
- proc ComputeFramePara near
-
- movzx ax,Angle
- mov si,ax
- add al,64 ; Angle+90 in a 360-deg system
- mov di,ax
-
- add si,si
- add di,di ; indexes in SinTab/CosTab
-
- mov ax,WH
- xor dx,dx
- mov cx,word ptr CosTab[si]
- imul cx
- shrd ax,dx,8
- add ax,_Ax_ ; ax = _ax_ + WH * cos (angle)
- mov _Bx_,ax ; store result
-
- mov ax,WH
- xor dx,dx
- mov cx,word ptr SinTab[si]
- imul cx
- shrd ax,dx,8
- sub ax,_Ay_
- neg ax ; ax = _ay_ - WH * sin (angle)
- mov _By_,ax ; store result
-
- mov ax,WW
- xor dx,dx
- mov cx,word ptr CosTab[di]
- imul cx
- shrd ax,dx,8
- add ax,_Ax_ ; ax = _ax_ + WW * cos (angle+90)
- mov _Cx_,ax ; store result
-
- mov ax,WW
- xor dx,dx
- mov cx,word ptr SinTab[di]
- imul cx
- shrd ax,dx,8
- sub ax,_Ay_
- neg ax ; eax = _ay_ - WW * sin (angle+90)
- mov _Cy_,ax ; store result
-
- ;
-
- mov ax,_Cx_
- sub ax,_Ax_
- cwd
- mov dh,dl ;
- mov dl,ah ; shld dx,ax,8
- mov ah,al ;
- mov al,0 ; shl ax,8
- mov cx,320
- idiv cx ; hAdvX = ((_cx_-_ax_) shl 8) div 320
- mov word ptr cs:smc1+1,ax ; SMCODE INIT
-
- mov ax,_Cy_
- sub ax,_Ay_
- cwd
- mov dh,dl ;
- mov dl,ah ; shld dx,ax,8
- mov ah,al ;
- mov al,0 ; shl ax,8
- mov cx,320
- idiv cx ; hAdvY = ((_cy_-_ay_) shl 16) div 320
- mov word ptr cs:smc2+1,ax ; SMCODE INIT
-
- mov ax,_Bx_
- sub ax,_Ax_
- cwd
- mov dh,dl ;
- mov dl,ah ; shld dx,ax,8
- mov ah,al ;
- mov al,0 ; shl ax,8
- mov cx,200
- idiv cx ; vAdvX = ((_bx_-_ax_) shl 16) div 200
- mov word ptr cs:smc3+1,ax ; SMCODE INIT
-
- mov ax,_By_
- sub ax,_Ay_
- cwd
- mov dh,dl ;
- mov dl,ah ; shld dx,ax,8
- mov ah,al ;
- mov al,0 ; shl ax,8
- mov cx,200
- idiv cx ; vAdvY = ((_by_-_ay_) shl 16) div 200
- mov word ptr cs:smc4+2,ax ; SMCODE INIT
-
- retn
- endp
-
- ;****************************************************************************
-
- GenFrame PROC NEAR
-
- push ds es si bp
-
- ; pusha ; in my example I don't need such sober instructions... :)
- ; but if the registers are vital to your application, feel
- ; free to erase the comment (see POPA, too!)
-
- call ComputeFramePara
-
- mov es,vScr
- xor di,di
-
- smc1: mov bp,1234h ;hAdvX
- smc2: mov si,1234h ;hAdvY
-
- mov ah,byte ptr _Ax_ ; starting coordinates
- mov dh,byte ptr _Ay_ ;
-
- mov al,0
- mov dl,al
-
- mov ds,Img[2] ; bitmap seg (from this point on)
-
- ;-- Loop 1 (200 times) ------------------------------------------------------
- mov cx,200
-
- Loop1: push cx
- push ax dx
-
- ;-- Loop 2 (320 times) ------------------------------------------------------
- mov cx,320
-
- Loop2: mov bl,ah ; X coord
- mov bh,dh ; Y coord
- mov bl,[bx]
- mov es:[di],bl
- inc di
- add ax,bp ; Horizontal-Advance-X factor
- add dx,si ; Horizontal-Advance-Y factor
- dec cx
- sjg Loop2
-
- ;-- End loop 2 --------------------------------------------------------------
-
- pop dx ax
- pop cx
-
- smc3: add ax,1234h ;vAdvX
- smc4: add dx,1234h ;vAdvY
-
- dec cx
- jg Loop1
-
- ;-- End loop 1---------------------------------------------------------------
-
- ; popa
-
- pop bp si es ds
-
- retn
-
- endp
-
-
- END
-